from pages.base_page import  BasePage
from selenium.webdriver.common.by import By

class NewCwPage(BasePage):
    url='crm/index.php?m=finance&a=add&t=receivables'
      #定位器
    # 应收款名
    ysk_name_locator = (By.NAME,"name")
    # 客户
    customer_locator = (By.ID,"customer")
    # kh_locator = (By.XPATH,'//*[@id="datas"]/tr[1]/td[1]/input[1]')
    kh_locator = (By.CSS_SELECTOR, "#datas > tr:nth-child(1) > td:nth-child(1) > input[type=radio]:nth-child(1)")

    # 收款金额
    price_locator = (By.ID, "price")
    # 点击ok
    button_ok_locator = (By.XPATH, "/html/body/div[7]/div[3]/div/button[1]/span")
    # 确定
    make_sure_locator = (By.XPATH, "/html/body/div[5]/div[2]/div/form/table/tfoot/tr/td[2]/input[1]")
    #取消
    cancel_ysk_locator=(By.XPATH,'/html/body/div[5]/div[2]/div/form/table/tfoot/tr/td[2]/input[3]')
    #填写应收款名
    def input_ysk_name(self,ysk_name):
        self.driver.find_element(*self.ysk_name_locator).send_keys(ysk_name)

    #选择客户
    def click_customer(self):
        self.driver.find_element(*self.customer_locator).click()
    #确定客户
    def click_kehu(self):
        self.driver.find_element(*self.kh_locator).click()

    #填写金额
    def input_price(self,price):
        self.driver.find_element(*self.price_locator).send_keys(price)
    #点击OK
    def click_ok(self):
        self.driver.find_element(*self.button_ok_locator).click()
    #点击保存
    def click_save_ysk(self):
        self.driver.find_element(*self.make_sure_locator).click()

    def click_cancel_add_ysk(self):
        self.driver.find_element(*self.cancel_ysk_locator).click()
